<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>

<html>
<head>
<script type="text/javascript" >



</script>

<script type="text/javascript">
var vehicleStatusJson;  
$(document).ready(function () {         
	
})


/**
 * 保存页面数据
 */
 function savevehicle() {
	//判断车辆编号是否为空
	var vehicleNoVal=$("#vehicleNo").val();
	if(vehicleNoVal==null||vehicleNoVal==""){
		var spans= document.getElementById("massage")
		spans.style="display:inline-block;color:red"
		return;
	} 
    //获取canvas的编码
    
    
    //将数据保存到数据库中
    $.ajax({
    	 url: "rest/vehicle/save.do",
    	 type:'post',
    	 data: { "vehicleNo":$("#vehicleNo").val() },  	 
    	 success:function (data){
    		 
      		 //返回到默认选中展示目录
      		 parent.showCenter('vehicle/index.do');
      		 
      		//'http://'+host+'/vehicleApi/addPhoto'
      	}

    	 });
} 
/**
 * 返回页面
 */
function back(url){
	$.get(url, {}, function(data){
		$("#center").empty();
        $("#center").html(data);
        $.parser.parse($("#center"));
    });
}
//查询可用人员和车辆
function searchcar(){
	
	
	var personJson;
	$.ajax({
		type : "get",
		url : 'rest/schedule/searchPerson.do',
		async : false,
		success : function(result) {
			if (result.retCode == '0000') {
				personJson=result.data;
			}
			else{
				personJson="";
			}
		}
	});
	
	
	$('#personId').combobox({
        data: personJson,
        valueField: 'id',
        textField: 'name',
        onLoadSuccess: function(param){
      	      $('#personId').combobox('setValue','');
  		}
        
    }); //end 
    
    
    var vehicleJson;
	$.ajax({
		type : "get",
		url : 'rest/schedule/searchVehicle.do',
		async : false,
		success : function(result) {
			if (result.retCode == '0000') {
				vehicleJson=result.data;
			}
			else{
				vehicleJson="";
			}
		}
	});
	
	
	$('#vehicleId').combobox({
        data: vehicleJson,
        valueField: 'id',
        textField: 'vehicleNo',
        onLoadSuccess: function(param){
      	  $('#vehicleId').combobox('setValue','');
  		}
        
    }); //end 

}
//保存
function save() {
	//$('#host-fm').birthday 编辑日期表单值，然后提交
    $('#host-fm').form('submit', {
        url: 'rest/schedule/save.do',        
        
        success: function (result) {
        	$.messager.progress('close'); 
            var result = eval('(' + result + ')');
            if (result.retCode=='0000') {
            	back('schedule/index.do');
                
            } else {
                $.messager.show({
                    title: 'Error',
                    msg: result.retMsg
                });
            }
        }
    });
}
</script>
</head>
<body>
		
<div class="linkbar"><a> 排班管理</a>/<a> 排班录入</a></div>
		<form id="host-fm" method="post" novalidate>
			<div class="fitem">
				<label>开始时间:</label> 
				<input id="beginTime" name="beginTime" class="easyui-datetimebox" data-options="required:true,editable:false" style="width:150px"/>
			</div>
			<div class="fitem">
				<label>结束时间:</label>
				<input id="endTime" name="endTime" class="easyui-datetimebox" data-options="required:true,editable:false" style="width:150px;"/>	
			</div>
			<br/>
			<div>
			<a href="#" class="easyui-linkbutton" iconCls="icon-blank" onclick="searchcar()">查询可用人员和车辆</a> 
			</div>
			<div class="fitem">
				<label>选择人员:</label> 
				<select id="personId" name="personId" class="easyui-combobox" style="width:100px" >
				</select> 
			</div>
			<div class="fitem">
				<label>选择车辆:</label> 
				<select id="vehicleId" name="vehicleId" class="easyui-combobox" style="width:100px" >
				</select> 
			</div>
			</form>
		</div>
		
<div id="dlg-buttons">
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" 	onclick="save()">保存</a> 
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="back('schedule/index.do')">返回</a>
</div>
		

</body>
</html>